package operation;

import book.Book;
import book.BookList;

import java.sql.SQLOutput;
import java.util.Scanner;

public class AddOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("添加图书");
        System.out.println("请输入书名:");
        String name = scanner.nextLine();
        System.out.println("请输入作者:");
        String author = scanner.nextLine();
        System.out.println("请输入价格:");
        int price = scanner.nextInt();
        System.out.println("请输入类型:");
        String none = scanner.nextLine();//读取nextInt 的回车,否则type直接读取然后结束
        String type = scanner.nextLine();

        Book book = new Book(name,author,price,type);
        bookList.setBook(book, bookList.getNumber());
        bookList.setNumber( bookList.getNumber() + 1 );

        System.out.println("添加成功");
    }

}
